/*
-------------------------------------------------------------------
BIE is Copyright 2001-2004 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
 */
/*
 * PrivilegeManager.java
 *
 * Created on January 23, 2003, 11:40 AM
 */

package com.webdeninteractive.bie.persistent.privileges;

import java.sql.*;
import java.util.*;
import java.io.*;

/**
 *
 * @author  jdepons
 */
public class Privileges {
        
    public static boolean doLookup(User user, Resource resource) throws SQLException,IOException{
        
        ArrayList roles = Role.findAll();
        for (int i =0; i< roles.size(); i++) {
            Role r = (Role)roles.get(i);
            if (r.isResourceIncluded(resource) && r.isUserIncluded(user)) {
                return true;
            }
        }
        return false;
    }
    
    public static boolean doLookup(User user, Role role) throws SQLException,IOException{
        return role.isUserIncluded(user);        
    }

    public static boolean doLookup(Role role, Resource resource) throws SQLException,IOException{
        return role.isResourceIncluded(resource);
    }
        
}
